home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / garfield.swf / scripts / frame_92 / PlaceObject2_882_18 / CLIPACTIONRECORD onClipEvent(load).as
Encoding:
Text File  |  2010-04-12  |  4.7 KB  |  170 lines

  1. onClipEvent(load){
  2.    function change_txt(x_num)
  3.    {
  4.       var _loc2_ = "";
  5.       if(x_num < 0)
  6.       {
  7.          _loc2_ = "-";
  8.          x_num = Math.abs(x_num);
  9.       }
  10.       if(x_num > 1000)
  11.       {
  12.          _loc2_ = Math.floor(x_num / 1000) + ",";
  13.          if(x_num % 1000 < 100)
  14.          {
  15.             _loc2_ += "0";
  16.             if(x_num % 1000 < 10)
  17.             {
  18.                _loc2_ += "0" + x_num % 1000;
  19.             }
  20.             else
  21.             {
  22.                _loc2_ += x_num % 1000;
  23.             }
  24.          }
  25.          else
  26.          {
  27.             _loc2_ += x_num % 1000;
  28.          }
  29.          _loc2_ += " km";
  30.       }
  31.       else
  32.       {
  33.          _loc2_ = x_num + " km";
  34.       }
  35.       return _loc2_;
  36.    }
  37.    function load_xml()
  38.    {
  39.       if(n_name != undefined && n_name != "")
  40.       {
  41.          if(country == undefined)
  42.          {
  43.             country = "";
  44.          }
  45.          sch_xml.load("http://www.foxinternational.com/garfield2/soccergame/GarfieldGame.php?name=" + escape(n_name) + "&country=" + escape(country) + "&score=" + la_score);
  46.          start_wait();
  47.          this.gotoAndStop(2);
  48.       }
  49.    }
  50.    function start_wait()
  51.    {
  52.       timer = setInterval(go_wait,10000,this);
  53.    }
  54.    function go_wait(obj)
  55.    {
  56.       stop_wait();
  57.       if(!loaded)
  58.       {
  59.          obj.gotoAndStop(4);
  60.       }
  61.    }
  62.    function stop_wait()
  63.    {
  64.       clearInterval(timer);
  65.    }
  66.    function loadschs(success)
  67.    {
  68.       if(success == true)
  69.       {
  70.          if(sch_xml.firstChild.childNodes.length == 0)
  71.          {
  72.             this.gotoAndStop(4);
  73.             loaded = false;
  74.          }
  75.          else
  76.          {
  77.             var _loc2_ = 0;
  78.             while(_loc2_ < sch_xml.firstChild.childNodes.length)
  79.             {
  80.                if(Number(sch_xml.firstChild.childNodes[_loc2_].attributes.score) >= 80000)
  81.                {
  82.                   score_ray.push({xname:sch_xml.firstChild.childNodes[_loc2_].attributes.name,score:80000,country:sch_xml.firstChild.childNodes[_loc2_].attributes.country,timestamp:Number(sch_xml.firstChild.childNodes[_loc2_].attributes.timestamp)});
  83.                }
  84.                else
  85.                {
  86.                   score_ray.push({xname:sch_xml.firstChild.childNodes[_loc2_].attributes.name,score:Number(sch_xml.firstChild.childNodes[_loc2_].attributes.score),country:sch_xml.firstChild.childNodes[_loc2_].attributes.country,timestamp:Number(sch_xml.firstChild.childNodes[_loc2_].attributes.timestamp)});
  87.                }
  88.                _loc2_ = _loc2_ + 1;
  89.             }
  90.             score_ray.sortOn(["score","timestamp"],[Array.DESCENDING | Array.NUMERIC,Array.DESCENDING | Array.NUMERIC]);
  91.             loaded = true;
  92.             gotoAndStop(3);
  93.          }
  94.          stop_wait();
  95.       }
  96.    }
  97.    function load_data(x_num1)
  98.    {
  99.       if(last_on >= 0)
  100.       {
  101.          eval("nav" + last_on).gotoAndStop(1);
  102.       }
  103.       last_on = x_num1;
  104.       eval("nav" + last_on).gotoAndStop(3);
  105.       var i = 0;
  106.       while(i <= 19)
  107.       {
  108.          eval("score_" + i).idnum = i + x_num1 + 1;
  109.          eval("score_" + i).n_name = score_ray[i + x_num1].xname;
  110.          eval("score_" + i).la_num = score_ray[i + x_num1].score;
  111.          eval("score_" + i).country = score_ray[i + x_num1].country;
  112.          if(eval("score_" + i).n_name == undefined)
  113.          {
  114.             eval("score_" + i).n_name = "";
  115.             eval("score_" + i).k_txt = "";
  116.             eval("score_" + i).country = "";
  117.             eval("score_" + i).la_num = 0;
  118.             eval("score_" + i)._visible = 0;
  119.          }
  120.          else
  121.          {
  122.             eval("score_" + i)._visible = 1;
  123.          }
  124.          eval("score_" + i).k_txt = change_txt(eval("score_" + i).la_num);
  125.          if(eval("score_" + i).la_num >= 80000)
  126.          {
  127.             eval("score_" + i).gotoAndStop(2);
  128.          }
  129.          else
  130.          {
  131.             eval("score_" + i).gotoAndStop(1);
  132.          }
  133.          i++;
  134.       }
  135.       if(x_num1 != 0)
  136.       {
  137.          prev_btn._visible = 1;
  138.       }
  139.       else
  140.       {
  141.          prev_btn._visible = 0;
  142.       }
  143.       if(x_num1 + 10 >= score_ray.length)
  144.       {
  145.          next_btn._visible = 0;
  146.       }
  147.       else
  148.       {
  149.          next_btn._visible = 1;
  150.       }
  151.    }
  152.    var la_score = Math.round(_parent.score * 80 / 21);
  153.    var la_num = la_score;
  154.    if(la_score > 80000)
  155.    {
  156.       score_txt = "YOU HAVE GONE AROUND THE WORLD!";
  157.    }
  158.    else
  159.    {
  160.       score_txt = "YOUR SCORE IS " + change_txt(la_num) + ".";
  161.    }
  162.    var sch_xml = new XML();
  163.    sch_xml.onLoad = loadschs;
  164.    sch_xml.ignoreWhite = true;
  165.    var loaded = false;
  166.    var timer = -1;
  167.    var score_ray = new Array();
  168.    var last_on = -1;
  169. }
  170.